﻿using System.Text.RegularExpressions;

namespace FastEasy.Common.Extension
{
    public static class RegexMatch
    {
        /// <summary>
        /// 检验是否手机号
        /// </summary>
        /// <param name="number">号码</param>
        /// <returns></returns>
        public static bool IsPhone(string number)
        {
            string phoneRegex = @"^1\d{10}$";
            return Regex.IsMatch(number, phoneRegex);
        }

        /// <summary>
        /// 检验是否邮箱
        /// </summary>
        /// <param name="number">号码</param>
        /// <returns></returns>
        public static bool IsEmail(string number)
        {
            string emailRegex = @"^\S+@\S+\.\S+$";
            return Regex.IsMatch(number, emailRegex);
        }
    }
}